// 鉴权识别
import { Navigate } from "react-router-dom";
import { message } from "antd";

function AuthRoute({ children }) {
	const token = localStorage.getItem("token");
	const componentsName = children?.type?.name || "";
	if (token) {
		const bol = componentsName === "Login";
		return bol ? <Navigate to={"/"} /> : <>{children}</>;
	} else {
		message.error("请重新登录");
		return <Navigate to={"/login"} replace />;
	}
}

export default AuthRoute;
